Keyboard and Mouse simulation is not working in macOS pre-login window

I'm a newbie to Launch agent and daemons. Now I'm currently developing the remote desktop (like VNC) application for macOS with Objective-C and my application supported macOS versions are 10.6 and later. I have created a pre-login agent and it will launch my application when login window open.


I am using CGEventPost to simulate keyboard and mouse events in user logged-in sessions. But it's not working in pre-login window (global login window)


Citrix, LogMeIn are providing the remote controls in Pre-login window too. How are they doing it?


Any help will be highly appreciated.


Please refer the code


//For Keyboard

CGEventRef keyEvent = CGEventCreateKeyboardEvent( NULL, keyCode, down ) ;

CGEventPost( kCGHIDEventTap, keyEvent ) ;

CFRelease( keyEvent ) ;


//For Mouse

CGEventRef event = CGEventCreateMouseEvent(eventSource, eventType, mouseLocation, mouseButton ); CGEventPost(kCGHIDEventTap, event);

CFRelease(event);


//Pre-login launch agent

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Label</key>

<string>my app label</string>

<key>LimitLoadToSessionType</key>

<string>LoginWindow</string>

<key>RunAtLoad</key>

<true/>

<key>WorkingDirectory</key>

<string>My app directory</string>

<key>ProgramArguments</key>

<array>

<string>app absolute path</string>

<string>service</string>

<string>myservice</string>

</array>

<key>KeepAlive</key>

<true/>

</dict>

</plist>

MacBook Pro with Retina display, Mac OS X (10.6)

Posted on Sep 15, 2016 1:38 AM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Keyboard and Mouse simulation is not working in macOS pre-login window

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.